// javamaps
// Copyright (c) 2010 Maris Ramona
package Core;
import java.io.*;

public final class Link implements Serializable {
    private ObjectId linkId_;
    private ObjectId nodeId_;
    private ObjectId streetId_;
    private int startPoint_;
    private int endPoint_;
    private double distance_;

    /*
     * Constructori.
     */
    public Link(ObjectId linkId, ObjectId nodeId, ObjectId streetId) {
        linkId_ = linkId;
        nodeId_ = nodeId;
        streetId_ = streetId;
    }

    public Link(ObjectId linkId, ObjectId nodeId, ObjectId streetId,
                int startPoint, int endPoint, double distance) {
         this(linkId, nodeId, streetId);
         startPoint_ = startPoint;
         endPoint_ = endPoint;
         distance_ = distance;
    }
   
    /*
     * Metode publice.
     */
    public ObjectId LinkId(){ return linkId_; }
    public void SetLinkId(ObjectId id){ linkId_ = id; }

    public ObjectId NodeId(){ return nodeId_; }
    public void SetNodeId(ObjectId id){ nodeId_= id; }

    public ObjectId StreetId(){ return streetId_; }
    public void SetStreetId(ObjectId id){ streetId_= id; }

    public int StartPoint(){ return startPoint_;}
    public void SetStartPoint(int value){ startPoint_ = value;}

    public int EndPoint(){ return endPoint_;}
    public void SetEndPoint(int value){ endPoint_ = value;}

    public double Distance(){ return distance_; }
    public void SetDistance(double distance){ distance_ = distance; }

    @Override
    public boolean equals(Object obj){
        if(obj == null) return false;
        if(this == obj) return true;
        if(this.getClass() != obj.getClass()) return false;

        Link link = (Link)obj;
        return link.linkId_.equals(linkId_);
   }

    @Override
    public int hashCode() {
        return linkId_.hashCode();
    }

    //Pentru debugging.
    @Override
    public String toString(){
        return "L=" + linkId_ +", N=" + nodeId_ +", S=" + streetId_ +
                ", Start=" + startPoint_ +", End=" + endPoint_;
    }
}